﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FOBVT.Web.MainClass;

namespace FOBVT.Web.Admin
{
	public partial class Login : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
		}

		protected void btnLogin_Click(object sender, EventArgs e)
		{
			System.Data.OleDb.OleDbConnection Conn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("..\\DB\\FOBVTweb.mdb"));

			MainClass.GetUserInfo userInfoClass = new MainClass.GetUserInfo();
			userInfoClass.Conn = Conn;
			userInfoClass.Email = txtEmail.Text.Trim();
			userInfoClass.Password = FOBVT.Web.MainClass.DEncrypt.Encrypt(txtPassword.Text.Trim());

			FOBVT.Web.MainClass.User result = userInfoClass.AdminLogin();

			if (result != null)
			{
				FOBVT.Web.MainClass.SessionState.CurrentUser = result;
				Response.Redirect("Index.aspx");
			}
			else
			{
				FOBVT.Web.MainClass.WebMessageBox.Show(this, "Logon failed！");
			}
		}
	}
}